package org.zxp.thread.base;

import org.junit.Test;

/**
 * @program: zxp-thread-test
 * @description: 推荐：1、不能多继承但是可以多实现 2、线程代码可以复用
 * @author: X-Pacific zhang
 * @create: 2019-05-06 18:58
 **/
public class MyRunable implements Runnable {
    @Override
    public void run() {
        System.out.println(Thread.currentThread().getName());
    }

    public static void main(String[] args){
        MyRunable myRunable = new MyRunable();
        Thread thread = new Thread(myRunable);
        thread.setName("MyRunable");
        thread.start();//开启新线程
//        thread.run();//不开启新线程，直接调用
    }

    @Test
    public void test(){
        new Thread(this ::run).start();
    }
}
